package com.ad.pet.app.mall.adapter;

import android.support.annotation.Nullable;
import android.view.View;
import android.widget.TextView;

import com.ad.pet.R;
import com.ad.pet.common.data.utils.date.DateUtil;
import com.ad.pet.models.remote.mall.Counpous;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;

import java.util.List;

/**
 * Created by SEELE on 2019/6/20.
 */

public class CounpousAdapter extends BaseQuickAdapter<Counpous,BaseViewHolder> {
    public CounpousAdapter(@Nullable List<Counpous> data) {
        super(R.layout.item_conpouns_layout,data);
    }

    @Override
    protected void convert(BaseViewHolder helper, Counpous item) {

        TextView tvSS = helper.getView(R.id.tv_ss);
        TextView textView = helper.getView(R.id.tv_coupon_name);
        TextView tvTime = helper.getView(R.id.tv_time);
        TextView tvSupport = helper.getView(R.id.tv_support);
        TextView tvDiscount = helper.getView(R.id.tv_discount);

        tvSupport.setText(item.getDesc());

        if (item.getPeriod_rule()==0){
            tvTime.setText("使用期限："+"无限期");
        }else {

            tvTime.setText("使用期限："+ DateUtil.stampToDate(Long.valueOf(item.getStart_time())*1000).replaceAll("-",".")+"-"+DateUtil.stampToDate(Long.valueOf(item.getEnd_time())*1000).replaceAll("-","."));
        }
        if (item.getPeriod_rule()==1){
            textView.setText(item.getVoucher_name()+"("+"平日使用"+")");
        }else if (item.getPeriod_rule()==2){
            textView.setText(item.getVoucher_name()+"("+"双休使用"+")");
        }else {
            textView.setText(item.getVoucher_name());
        }

        if (Double.valueOf(item.getDiscount())>0){
            String zhekou = ""+(Double.valueOf(item.getDiscount())*10);
            zhekou =zhekou.replace(".0","");
            tvDiscount.setText(zhekou+"折");
            tvDiscount.setVisibility(View.VISIBLE);
            tvSS.setText("折扣券");
        }else {
            tvSS.setText("抵用券");
            tvDiscount.setVisibility(View.GONE);
        }











    }
}
